$(document).ready(function(){
    
    var cookieName = 'accordionStats';
    
    var accordion = $( "#accordion" ).accordion({
        collapsible: true,
        autoHeight: false,
        active: ( $.cookies.get( cookieName ) || 0 ),
        change: function( e, ui )
        {
            $.cookies.set( cookieName, $( this ).find( 'h3' ).index ( ui.newHeader[0] ) );
        }
    });
    
    var data = [];
     $(".typeTraitement").each(function (i) {
         var nbTraitements = parseInt($(this).text());
         var nomTypeTraitement = $(this).attr('id').split('_')[2];
         data.push([nomTypeTraitement, nbTraitements]);
     });

    var plot1 = jQuery.jqplot (
        'chartTraitements',
        [data],
        {
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {padding: 8, showDataLabels: true, dataLabels: 'value'}
        },
        legend: {show:true, location: 'e'},
        grid: {
            drawBorder: false,
            drawGridlines: false,
            background: '#ffffff',
            shadow:false
        },
        seriesColors: ['#83D983', '#F7F771', '#8983D9', '#D98383', '#83C5D9', '#F3CB6D', '#724E45', '#799B71']
        }
    );
        
        
        
    var nbLot = parseInt($(document).find('#nbLot').text());
    var nbLotConf = parseInt($(document).find('#nbLotConf').text());

   
    var data = [
        ['Lots non confidentiels', nbLot-nbLotConf],
        ['Lots confidentiels', nbLotConf]
    ];
    var plot1 = jQuery.jqplot (
        'chartLots',
        [data],
        {
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {padding: 8, showDataLabels: true, dataLabels: 'value'}
        },
        legend: {show:true, location: 'e'},
        grid: {
            drawBorder: false,
            drawGridlines: false,
            background: '#ffffff',
            shadow:false
        },
        seriesColors: ['#83D983', '#D9D983', '#8983D9', '#D98383', '#83C5D9']
        }
    );
});